package com.ruoyi.webshop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.webshop.domain.AdvertType;
import com.ruoyi.webshop.service.IAdvertTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广告信息类型Controller
 * 
 * @author ruoyi
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/webshop/AdvertType")
public class AdvertTypeController extends BaseController
{
    @Autowired
    private IAdvertTypeService advertTypeService;

    /**
     * 查询广告信息类型列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:AdvertType:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdvertType advertType)
    {
        startPage();
        List<AdvertType> list = advertTypeService.selectAdvertTypeList(advertType);
        return getDataTable(list);
    }

    /**
     * 导出广告信息类型列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:AdvertType:export')")
    @Log(title = "广告信息类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdvertType advertType)
    {
        List<AdvertType> list = advertTypeService.selectAdvertTypeList(advertType);
        ExcelUtil<AdvertType> util = new ExcelUtil<AdvertType>(AdvertType.class);
        util.exportExcel(response, list, "广告信息类型数据");
    }

    /**
     * 获取广告信息类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('webshop:AdvertType:query')")
    @GetMapping(value = "/{advertTypeId}")
    public AjaxResult getInfo(@PathVariable("advertTypeId") Long advertTypeId)
    {
        return success(advertTypeService.selectAdvertTypeByAdvertTypeId(advertTypeId));
    }

    /**
     * 新增广告信息类型
     */
    @PreAuthorize("@ss.hasPermi('webshop:AdvertType:add')")
    @Log(title = "广告信息类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdvertType advertType)
    {
        return toAjax(advertTypeService.insertAdvertType(advertType));
    }

    /**
     * 修改广告信息类型
     */
    @PreAuthorize("@ss.hasPermi('webshop:AdvertType:edit')")
    @Log(title = "广告信息类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdvertType advertType)
    {
        return toAjax(advertTypeService.updateAdvertType(advertType));
    }

    /**
     * 删除广告信息类型
     */
    @PreAuthorize("@ss.hasPermi('webshop:AdvertType:remove')")
    @Log(title = "广告信息类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{advertTypeIds}")
    public AjaxResult remove(@PathVariable Long[] advertTypeIds)
    {
        return toAjax(advertTypeService.deleteAdvertTypeByAdvertTypeIds(advertTypeIds));
    }
}
